package com.bkhc.common.util;

import java.lang.reflect.Field;
import java.util.Map;

public class JavaBeanUtils {

    public static Object convert(Map<String,String> map, Class zclass){
        Field[] fields = zclass.getDeclaredFields();
        Object o = null;
        try {
            o = zclass.newInstance();
            for (Field field:fields){
                field.setAccessible(true);
                String value = map.get(field.getName()) !=null ?map.get(field.getName()).toString():null;
                field.set(o,value);
            }
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
        return o;

    }
}
